package com.gopay.common.cps.dao.wallet.base.impl;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.wallet.base.WaCertificateAllocationDao;
import com.gopay.common.domain.dps.WaCertificateAllocation;
/**
 * 移动端企业版数字证书分配实现类
 * @author ZHOUPENG
 * @date   2017年12月4日 上午10:11:55
 */
@Service("waCertificateAllocationDao")
public class WaCertificateAllocationDaoImpl extends BaseDAOImpl<WaCertificateAllocation, Serializable> implements WaCertificateAllocationDao {
	/**
     * @Description: 获取已分配但未安装的数据
     * @param dtlId
     * @return 
     * @author liuxuyang
     */
	@Override
    public int getUnUsedAllocate(Long dtlId) {
    	String hql = "from WaCertificateAllocation where allocationStatus = :allocationStatus and "
				   + "certBuyId = :certBuyId ";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("allocationStatus", "02");
		param.put("certBuyId",dtlId);
		
		List<WaCertificateAllocation> list = findByHql(hql, param);
		if (null == list) {
			return 0;
		}
		return list.size();
    }
}
